package com.david.service;

import com.david.dao.ArticleContentDao;
import com.david.model.api.ArticleContent;
import com.david.utils.DateTimeUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleContentService {

    @Resource
    ArticleContentDao articleContentDao;

    public List<ArticleContent> findAll(){
        return articleContentDao.findAll();
    }

    public List<ArticleContent> findByparentIdType( Integer parentId,  String type){
        return articleContentDao.findByparentIdType(parentId,type);
    }

    public ArticleContent findById(Integer id){
        return articleContentDao.findById(id);
    }

    public int delete(Integer id){
        return articleContentDao.delete(id);
    }

    public int update(ArticleContent articleContent){
        return articleContentDao.update(articleContent);
    }

    public int insert(ArticleContent articleContent){
        articleContent.isDelete = false;
        articleContent.createTime = DateTimeUtils.GetPSTDateTime();
        articleContent.sort = 0;
        return articleContentDao.insert(articleContent);
    }

    public int updateSort(Integer sort,Integer id){
        return articleContentDao.updateSort(sort,id);
    }
}
